(function (ns) {

  var Asset = ns.Asset = Hilo.Class.create({
    Mixes: Hilo.EventMixin,

    queue: null,
    bg: null,
    ground: null,
    ready: null,
    over: null,
    numberGlyphs: null,
    number2Glyphs: null,
    birdAtlas: null,
    holdback: null,
    circle: null,
    curtains: null,
    arc: null,
    backBtn: null,
    word1: null,
    word2: null,
    word3: null,

    load: function () {
      var resources = [
        {id: 'bg', src: 'images/bg3.png'},
        {id: 'number2', src: 'images/number2.png'},
        {id: 'circle', src: 'images/3round@2x.png'},
        {id: 'curtains', src: 'images/3curtain@2x.png'}, // 窗帘
        {id: 'start', src: 'images/gamestart.png'},      // 开始按键
        {id: 'arc', src: 'images/3slide.png'},      // 开始按键
        {id: 'backBtn', src: 'images/3back.png'},      // 回到首页

        {id: 'word1', src: 'images/3word1.png'},      // 游戏文字1
        {id: 'word2', src: 'images/3word2.png'},      // 游戏文字2
        {id: 'word3', src: 'images/3word3.png'},      // 游戏文字3
        // {id:'music1', src:'media/1C.mp3'},
        // {id:'music2', src:'media/2D.mp3'},
        // {id:'music3', src:'media/3E.mp3'},
        // {id:'music4', src:'media/4F.mp3'},
        // {id:'music5', src:'media/5G.mp3'},
        // {id:'music6', src:'media/6A.mp3'},
        // {id:'music7', src:'media/7B.mp3'}
      ];

      this.queue = new Hilo.LoadQueue();
      this.queue.add(resources);
      this.queue.on('load', this.onLoad.bind(this));
      this.queue.on('error', this.onLoadError.bind(this));
      this.queue.on('complete', this.onComplete.bind(this));

      this.queue.start();
    },
    // 当单个资源下载完成时发生
    onLoad: function () {
      // 获取全部或已下载的资源的字节大小。默认为全部。
      // console.log(this.queue);
      // console.log(this.queue.getSize(false), 'false');
      // console.log(this.queue.getSize(true), 'true');
      // console.log('---------')
      // console.log(this.queue.getLoaded())
    },
    // 当某一资源下载出错时发生
    onLoadError: function (e) {
      console.log('资源下载出错时');
      console.log(e);
    },
    onComplete: function (e) {
      this.bg = this.queue.get('bg').content;

      this.circle = this.queue.get('circle').content;
      this.curtains = this.queue.get('curtains').content;
      this.start = this.queue.get('start').content;
      this.arc = this.queue.get('arc').content;
      this.backBtn = this.queue.get('backBtn').content;
      this.word1 = this.queue.get('word1').content;
      this.word2 = this.queue.get('word2').content;
      this.word3 = this.queue.get('word3').content;


      var number2 = this.queue.get('number2').content;

      this.number2Glyphs = {
        0: {image: number2, rect: [0, 0, 40 , 64]},
        1: {image: number2, rect: [41, 0, 40, 64]},
        2: {image: number2, rect: [81 + 2, 0, 40 + 2, 64]},
        3: {image: number2, rect: [121 + 2, 0, 40 + 2, 64]},
        4: {image: number2, rect: [161 + 2, 0, 40 + 2, 64]},
        5: {image: number2, rect: [201 + 2 + 2, 0, 40 + 2, 64]},
        6: {image: number2, rect: [241 + 2 + 1, 0, 40 + 2, 64]},
        7: {image: number2, rect: [281 + 2 + 1, 0, 40 + 2, 64]},
        8: {image: number2, rect: [321 + 2 + 4, 0, 40 + 2, 64]},
        9: {image: number2, rect: [361 + 2 + 7, 0, 40 + 2, 64]}
      };

      this.queue.off('complete');
      this.fire('complete');
    }

  });

})(window.game);